package com.fitso.model.service.user;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.fitso.model.bean.User;
import com.fitso.model.dao.UserDao;

/**
 * Simple user service that doesn't have any authentication. This should never
 * be used in a proudction setting.
 * 
 * @author timothystorm
 */
@Service(value = "SimpleUserService")
public class SimpleUserService implements UserService {

	@Resource(name = "HibernateUserDao")
	private UserDao _userDao;

	public void setUserDao(UserDao userDao) {
		_userDao = userDao;
	}

	public void save(User user) {
		_userDao.createOrUpdate(user);
	}

	public void edit(User user) {
		_userDao.createOrUpdate(user);
	}

	public void delete(User user) {
		_userDao.delete(user);
	}

	public User fetch(Long id) {
		return _userDao.readById(id);
	}

	public User fetch(String email, String password) {
		return _userDao.readByEmail(email);
	}

	public List<User> fetch() {
		return _userDao.read();
	}
}
